package com.haha.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;

import com.haha.info.MainMenuInfo;
import com.haha.mylife.R;

public class MainMenuAdapter  extends HahaBaseAdapter<MainMenuInfo>{

	public MainMenuAdapter(Context context, List<MainMenuInfo> list) {
		super(context, list);		
	}
	@Override
	public View getView(int arg0, View v, ViewGroup arg2) {
		ViewHolder vh=null;
		if(v==null){
			v=inflater.inflate(R.layout.main_list_item, arg2,false);
			vh=new ViewHolder(v);
			v.setTag(vh);
		}else{
			vh=(ViewHolder) v.getTag();
		}
		MainMenuInfo mmi=getItem(arg0);
		
		vh.imgHeader.setImageResource(mmi.getImgId());
		vh.txtInfo.setText(mmi.getText());
		/*if(arg0==0){
			v.setBackgroundResource(R.drawable.list_first);
		}else if(arg0==getCount()-1){
			v.setBackgroundResource(R.drawable.list_last);
		}else{
			v.setBackgroundResource(R.drawable.list_middle);
		}*/		
		return v;
	}
	
	class ViewHolder{
		@Bind(R.id.txtInfo) TextView txtInfo;
		@Bind(R.id.imgHeader) ImageView imgHeader;
		ViewHolder(View v){
			ButterKnife.bind(this,v);
		}
	}

}
